﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using ScriptManager.Data.Domain.Entities;
using ScriptManager.Data.Domain.Interfaces;

namespace ScriptManager.Data.Domain.Services
{
    public class DataService : IDataService
    {
        private IScriptRepository _scriptRepository;
        private IScriptRevisionRepository _scriptRevisionRepository;
        private IAuthorRepository _authorRepository;

        /// <summary>
        /// Initializes a new instance of the DataAccess class.
        /// </summary>
        public DataService(IScriptRepository scriptRepository,
                           IScriptRevisionRepository scriptRevisionRepository,
                           IAuthorRepository authorRepository)
        {
            _scriptRepository = scriptRepository;
            _scriptRevisionRepository = scriptRevisionRepository;
            _authorRepository = authorRepository;
        }

        public Script CreateNewScript(string name, string fund, string shortDescription)
        {
            return Script.New(name, fund, shortDescription); //Used only to set defaults for entity
        }

        public Author CreateNewAuthor(string firstName, string lastName)
        {
            return Author.New(firstName, lastName); //Used only to set defaults for entity
        }

        public void SaveAuthor(Author author)
        {
            _authorRepository.SaveOrUpdate(author);
        }
    }
}
